<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>规则集信息列表</title>
<link href="../../static/plugin/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../../static/plugin/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/plugin/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/plugin/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/plugin/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/plugin/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js" type="text/javascript"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
</head>
<script type="text/javascript">

	function doAdd(){
		JLEUtil.createModalWin('新增', 'SRuleCollInfoAdd.html');
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改', 'SRuleCollInfoUpdate.html?' + 'ruleCollId=' + row.ruleCollId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = {"ruleCollId": row.ruleCollId, "createUser": row.createUser};
					$.restfulDelete('../../api/s/rule/coll/info', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','SRuleCollInfoView.html?' + '&ruleCollId=' + row.ruleCollId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doInvalid(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.get("../../api/s/rule/coll/info/invalid/" + row.ruleCollId, function(data) {
                $.messager.alert('提示',data.message,'info');
                reloadList();
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doCopy(){
	    if ($('#copyBtn').attr("disabled")) {
	        return;
        }
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('复制提示', '你确定要复制这条记录?', function(r){
                if (r){
                    $('#copyBtn').attr("disabled", true);
                    $.ajax({
                        url: "../../api/s/rule/coll/copy",
                        type:"POST",
                        data:JSON.stringify(row),
                        contentType:"application/json;charset=utf-8",
                        dataType:"json",
                        success : function(data) {
                            $('#copyBtn').removeAttr("disabled");
                            var flag = data.code;
                            if(flag=='0'){
                                $.messager.alert('提示',data.message,'info');
                                reloadList();
                                return true;
                            }else{
                                $.messager.alert("提示", data.message,'error');
                                return false;
                            }
                        }
                    });
                }
            });

        } else {
            $.messager.alert('提示','请选择一条记录！','info');
        }
	}

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};

	function query() {
        $('#dg').datagrid('load', $("#searchForm").serializeJson());
	}
</script>
<body class="easyui-layout">
<div data-options="region:'north',title:'',minHeight: 100">
	<form id="searchForm" class="control-form center-block ">
		<div class="row">
			<div class="form-group col-md-4 row">
				<label for="ruleCollId" class="col-md-4 control-label">规则集编号：</label>
				<div class="col-md-8">
					<input type="text" class="form-control input-sm" name="ruleCollId" id="ruleCollId">
				</div>
			</div>
			<div class="form-group col-md-4 row">
				<label for="ruleCollType" class="col-md-4 control-label">规则集类型：</label>
				<div class="col-md-8">
					<select class="easyui-combobox"
							id="ruleCollType" name="ruleCollType"
							style="width: 100%; height: 25px;"
							data-options="required:false,editable:false,valueField:'enname',textField:'cnname',data:RULE_COLL_TYPE">
					</select>
				</div>
			</div>
			<div class="form-group col-md-4 row">
				<label for="ruleCollDesc" class="col-md-4 control-label">规则集名称：</label>
				<div class="col-md-8">
					<input type="text" class="form-control input-sm" name="ruleCollDesc" id="ruleCollDesc">
				</div>
			</div>
		</div>
		<div class="row">
			<div class="form-group col-md-12 text-center">
				<a class="easyui-linkbutton" href="javascript:void(0);" onclick="query()">查找</a>
				<a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a>
			</div>
		</div>
	</form>
</div>
<div data-options="region:'center',split:false">
<table id="dg" class="easyui-datagrid" title="" style="width:100%;height:100%"
			data-options="singleSelect:true,collapsible:true,url:'../../api/s/rule/coll/infos',method:'post'"
			toolbar="#tb"
		title="Load Data" 
		rownumbers="true" pagination="true" pageSize="20">
		<thead>
			<tr>
				<th data-options="field:'ruleCollId',resizable:true" >规则集编号</th>
				<th data-options="field:'ruleCollDesc',resizable:true,width:250" >规则集名称</th>
				<th data-options="field:'ruleCollType',resizable:true,width:250" formatter="formatter_RULE_COLL_TYPE">规则集类型</th>
				<th data-options="field:'ruleCollVersion',resizable:true" >规则集版本</th>
				<th data-options="field:'ruleCollState',resizable:true" formatter="formatter_RULE_COLL_STATE">规则集状态</th>
				<th data-options="field:'createUser',resizable:true" >创建用户</th>
				<th data-options="field:'createTime',resizable:true" >创建日期</th>
				<th data-options="field:'updateTime',resizable:true" >最后修改时间</th>
				<th data-options="field:'updateUser',resizable:true" >最新变更用户</th>
			</tr>
		</thead>
	</table>
</div>
<div id="tb" style="padding:1px">
	<div style="margin-bottom:2px">
		<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true">新增</a>
		<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a>
		<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
		<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">查看</a>
		<a href="javascript:doInvalid()" class="easyui-linkbutton" iconCls="icon-clear" plain="true">失效</a>
		<a href="javascript:doCopy()" class="easyui-linkbutton" iconCls="icon-cut" plain="true" id="copyBtn">复制</a>
	</div>
</div>
</body>
</html>
